<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-remove"></li></button>
    <h5 class="modal-title"></h5>
</div>

<div class="modal-body">
    <form id="camera_form" name="camera_form" class="form-horizontal">
        <input type="hidden" name="id">
        <input type="hidden" name="version">
        <input type="hidden" name="createDateTime" data-flag="date" data-format="yyyy-mm-dd hh:ii:ss">
        <input type="hidden" name="deleted" value="0">
        <input type='hidden' value="${CSRFToken}" id='csrftoken'>
        <div class="box-body">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">序列号<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="deviceSerial" name="deviceSerial" placeholder="请填写序列号">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">摄像头名称<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="name" name="name" placeholder="请填写名称">
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-3 control-label">摄像头地址</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="cameraAdd" name="cameraAdd" placeholder="请填写摄像头地址">
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-3 control-label">云台控制<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <select id="cameraType" name="cameraType" class="form-control">
                            <option selected value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                
                
                <div class="form-group">
                    <label class="col-sm-3 control-label">通道号<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="channelNo" name="channelNo" placeholder="请填写通道号">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">RTMP高清地址</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="rtmpHd" name="rtmpHd" placeholder="请填写RTMP高清地址">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">RTMP地址<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="rtmp" name="rtmp" placeholder="请填写RTMP地址">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">HLS高清地址</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="hlsHd" name="hlsHd" placeholder="请填写HLS高清地址">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">HLS地址<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="hls" name="hls" placeholder="请填写HLS地址">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">直播地址<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="ziboUrl" name="ziboUrl" placeholder="请填写直播地址">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">APPKEY<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="appKey" name="appKey" placeholder="请填写APPKEY">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">APPSECRET<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="appSecret" name="appSecret" placeholder="请填写APPSECRET">
                    </div>
                </div>
            </div>
        </div>
        <div class="box-footer text-right">
            <button type="button" class="btn btn-default" data-btn-type="cancel" data-dismiss="modal">取消</button>
            <button type="submit" class="btn btn-primary" data-btn-type="save">提交</button>
        </div>
    </form>
</div>
<script>
    var form;
    var id="${id?default(0)}";
    $(function(){
        //初始化表单
        form=$("#camera_form").form();
        //数据校验
        $("#camera_form").bootstrapValidator({
            message : '请输入有效值',
            feedbackIcons : {
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            submitHandler : function() {
                modals.confirm('确认保存？', function() {
                    var camera = form.getFormSimpleData();
                    ajaxPost(basePath+'/camera/save',camera, function(data) {
                        if(data.success){
                            if(id!="0"){
                                modals.hideWin(winId);
                                cameraTable.reloadRowData(id);
                            }else{
                                modals.hideWin(winId);
                                cameraTable.reloadData();
                            }
                        }
                    });
                });
            },
            fields : {
                "deviceSerial":{
                    validators:{
                        notEmpty:{message:'设备序列号不能为空'}
                    }
                },
                "name":{
                    validators:{
                        notEmpty:{message:'设备名称不能为空'}
                    }
                },
                "channelNo":{
                    validators:{
                        notEmpty:{message:'通道号不能为空'},
integer:{message:'请填写整数'}
                    }
                },
                "rtmpHd":{
                    validators:{
                        notEmpty:{message:'RTMP高清地址不能为空'}
                    }
                },
                "rtmp":{
                    validators:{
                        notEmpty:{message:'RTMP地址不能为空'}
                    }
                },
                "hlsHd":{
                    validators:{
                        notEmpty:{message:'HLS高清地址不能为空'}
                    }
                },
                "hls":{
                    validators:{
                        notEmpty:{message:'HLS地址不能为空'}
                    }
                },
                "ziboUrl":{
                    validators:{
                        notEmpty:{message:'直播地址不能为空'}
                    }
                },
                "appKey":{
                    validators:{
                        notEmpty:{message:'APPKEY不能为空'}
                    }
                },
                "appSecret":{
                    validators:{
                        notEmpty:{message:'APPSECRET不能为空'}
                    }
                }
            }
        });
        //初始化控件
        form.initComponent();
        //编辑回填
        if(id!=0){
            ajaxPost(basePath+"/camera/get/"+id,null,function(data){
                form.initFormData(data);
            })
        }
    });

</script>
